package com.shenyong.ladmin.controller;

import com.shenyong.ladmin.entity.Advertising;
import com.shenyong.ladmin.logConfig.Log;
import com.shenyong.ladmin.logConfig.OperationType;
import com.shenyong.ladmin.result.Page;
import com.shenyong.ladmin.service.AdvertisingService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @site
 * @company
 * @create
 */
@RestController
@RequestMapping("/adver")
public class AdvertisingController {
    @Autowired
    private AdvertisingService advertisingService;
    @RequiresAuthentication
    @RequestMapping("/AdverPage")
    public Map<String,Object> AdverPage(Page page){
        return advertisingService.getAdverPage(page);
    }
    @RequiresAuthentication
    @Log(describe = "增加一条广告信息",operationType= OperationType.INSERT)
    @RequestMapping("/AdverInsert")
    public int AdverInsert(Advertising advertising) {
        return advertisingService.AdverInsert(advertising);
    }
    @RequiresAuthentication
    @Log(describe = "修改广告信息",operationType= OperationType.UPDATE)
    @RequestMapping("/AdverUpdate")
    public int AdverUpdate(Advertising advertising){
        return advertisingService.AdverUpdate(advertising);
    }
    @RequiresAuthentication
    @Log(describe = "删除广告",operationType= OperationType.DELETE)
    @RequestMapping("/Adverdelete")
    public int Adverdelete(int id) {
        return advertisingService.Adverdelete(id);
    }
    @RequestMapping("/getAdvAll")
    public List<Advertising> selectAll() {
        return advertisingService.selectAll();
    }

}
